//
//  RDLogMediator.h
//  RDelivery
//
//  Created by selmerzhang on 2021/8/9.
//  Copyright © 2021 Tencent. All rights reserved.
//

#ifndef RDLogMediator_h
#define RDLogMediator_h

#import <RaftInterface/RAFTLogProtocol.h>
#import "RDeliverySDKSettings.h"

#define RDLogVerbose(sdkSettings,logTag,fmt,...) [sdkSettings.mediatorCenter.logMediator log:RAFTLogLevelVerbose \
tag:logTag fileName:__FILE_NAME__ lineNumber:__LINE__ function:__func__ content:fmt,##__VA_ARGS__]
#define RDLogDebug(sdkSettings,logTag,fmt,...) [sdkSettings.mediatorCenter.logMediator log:RAFTLogLevelDebug \
tag:logTag fileName:__FILE_NAME__ lineNumber:__LINE__ function:__func__ content:fmt,##__VA_ARGS__]
#define RDLogInfo(sdkSettings,logTag,fmt,...)  [sdkSettings.mediatorCenter.logMediator log:RAFTLogLevelInfo \
tag:logTag fileName:__FILE_NAME__ lineNumber:__LINE__ function:__func__ content:fmt,##__VA_ARGS__]
#define RDLogWarn(sdkSettings,logTag,fmt,...)  [sdkSettings.mediatorCenter.logMediator log:RAFTLogLevelWarn \
tag:logTag fileName:__FILE_NAME__ lineNumber:__LINE__ function:__func__ content:fmt,##__VA_ARGS__]
#define RDLogError(sdkSettings,logTag,fmt,...) [sdkSettings.mediatorCenter.logMediator log:RAFTLogLevelError \
tag:logTag fileName:__FILE_NAME__ lineNumber:__LINE__ function:__func__ content:fmt,##__VA_ARGS__]
#define RDLogFatal(sdkSettings,logTag,fmt,...) [sdkSettings.mediatorCenter.logMediator log:RAFTLogLevelFatal \
tag:logTag fileName:__FILE_NAME__ lineNumber:__LINE__ function:__func__ content:fmt,##__VA_ARGS__]


NS_ASSUME_NONNULL_BEGIN

@interface RDLogMediator : NSObject

/// 根据注入初始化中间层
/// @param logImpl 实现了RAFTLogProtocol协议的实例
/// @param settings RDeliverySDK的设置项
- (instancetype)initWithImpl:(id<RAFTLogProtocol>)logImpl settings:(RDeliverySDKSettings *)settings;

/// 输出日志
/// @param tag 日志标签
/// @param level 日志等级
/// @param fileName 所处文件的名称
/// @param lineNumber 行数
/// @param function 函数名
/// @param format 日志内容
- (void)log:(RAFTLogLevel)level
        tag:(NSString *)tag
   fileName:(const char *)fileName
 lineNumber:(int)lineNumber
   function:(const char *)function
    content:(NSString *)format,...;

@end

NS_ASSUME_NONNULL_END

#endif /* RDLogMediator_h */
